﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class MenuParent : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            load_All_MenuParent();
        }
    }

    public void load_All_MenuParent()
    {
        MenuParentRepeater.DataSource = BusLogic.MenuParent.get_ALL_MENUPARENT();
        MenuParentRepeater.DataBind();
    }

    protected void lbtDelete_Click(object sender, EventArgs e)
    {
        foreach (RepeaterItem item in MenuParentRepeater.Items)
        {
            CheckBox cb = (CheckBox)item.FindControl("cbxCheckMenuParent");

            if (cb.Checked == true)
            {
                TextBox txtMenuParentId = (TextBox)item.FindControl("txtMenuParentId");                
                BusLogic.MenuParent.remove_MENUPARENT(int.Parse(txtMenuParentId.Text));
            }
        }

        load_All_MenuParent();
        cbxCheckALLMenuParent.Checked = false;
    }

    protected void cbxCheckALLMenuParent_CheckedChanged(object sender, EventArgs e)
    {
        if (cbxCheckALLMenuParent.Checked == true)
        {
            foreach (RepeaterItem item in MenuParentRepeater.Items)
            {
                CheckBox cbxCheckMenuParent = item.FindControl("cbxCheckMenuParent") as CheckBox;
                cbxCheckMenuParent.Checked = true;
            }
        }
        else
        {
            foreach (RepeaterItem item in MenuParentRepeater.Items)
            {
                CheckBox cbxCheckMenuParent = item.FindControl("cbxCheckMenuParent") as CheckBox;
                cbxCheckMenuParent.Checked = false;
            }
        }
    }
}
